***JOP Kane, Mason, and Wronski****
***Supplemental Appendix Figures and Tables -- CCES Survey data***
use "JOP_KMW_CCES.dta" file

*********************TABLE A1. List of Party Coalition Groups and Respective Factor Loadings************
***************************************
*Obtain Factor Loadings and Generate Factor Scores
***************************************

**Each item measures of how close someone feels towards each of the 9 groups
**these are worded and coded the same as the group close to party items

revrs UMS391
revrs UMS392
revrs UMS393
revrs UMS394
revrs UMS395
revrs UMS396
revrs UMS397
revrs UMS398
revrs UMS399
**Dem groups Women, Blacks, Atheists, Muslims, Hispanics, Feminists
factor revUMS391 revUMS394 revUMS395 revUMS397 revUMS398 revUMS399, factors(1)
predict DemGroups_pfscore
**Rep groups Men, Whites, Christians
factor revUMS392 revUMS393 revUMS396, factors(1)
predict GOPgroups_pfscore


*********************TABLE B1. Sample Characteristics************
***descriptive for N=1000 sample
sum income, d
sum age, d
tab gender
tab white
tab black
tab hisp
tab pid7
tab ideology
sum polint, d

**descriptives for N=751 sample
sum income if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=., d

sum age if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=., d

tab gender if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

tab white if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

tab black if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

tab hisp if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

tab pid7 if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

tab ideology if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=.

sum polint if revpartyid01!=. & women_close!=. &  men_close!=. & whites_close!=. & ///
blacks_close!=. & atheist_close!=. & christ_close!=. & muslim_close!=. & ///
hisp_close!=. & fem_close!=. & dem_perceptual!=. & rep_perceptual!=. & ///
polint!=. & age01!=. & age01sq!=. & educ01!=. & income01!=. & gender!=. & ///
white!=. & black!=. & hisp!=. & christ!=. & no_relig!=. & attend01!=., d


*********************FIGURE C2. Distributions of Closeness Toward Party Coalitions************
	*Democratic Coalition
hist DemGroups_pfscore, percent norm scheme(plotplain) xtitle({bf:Democratic Coalition Score}) ///
	ytitle({it: Percent})
	
	*Republican Coalition
hist GOPgroups_pfscore, percent norm scheme(plotplain) xtitle({bf:Republican Coalition Score}) ///
	ytitle({it: Percent})


*********************TABLE D1. Regression Model Output for Figures 2 & 3************
**Figure 2 Model
reg partyid DemGroups_pfscore GOPgroups_pfscore ///
	dem_perceptual01 rep_perceptual01 ///
	polint age01 educ01 income01 gender ///
	black hisp other_race /// white= baseline
	catholic mormon jewish other_rel no_relig attend01, robust // protestant= baseline
	
**Figure 3 Model
reg partyid c.DemGroups_pfscore##c.dem_perceptual01 c.GOPgroups_pfscore##c.rep_perceptual01 ///
	polint age01 educ01 income01 gender ///
	black hisp other_race /// white= baseline
	catholic mormon jewish other_rel no_relig attend01, robust // protestant= baseline	
	
	
*****************FIGURE D1.  Alternative Figure 2 with Additive Scales for Coalition Scores************	
**Group sentiments IV operationalized as additive scale, N=785
reg partyid DemGroups_additive GOPgroups_additive ///
	dem_perceptual01 rep_perceptual01 polint age01 ///
	educ01 income01 gender ///
	black hisp other_race ///
	catholic mormon jewish other_rel no_relig attend01, robust
	
coefplot, drop(_cons) ci(95) xline(0) scheme(plottig) xlabel(-5(1)5)  ///
coeflabels (DemGroups_additive = "{bf: Democratic Coalition Score}" GOPgroups_additive = "{bf: Republican Coalition Score}" ///
dem_perceptual01 = "Perceptual Accuracy (Dem Groups)" rep_perceptual01 = "Perceptual Accuracy (Rep Groups)" ///
polint= "Political Interest" age01 = "Age" educ01 = "Education" income01 = "Income" gender = "Female" ///
black = "African-American" hisp = "Hispanic" other_race = "Other Racial Identification" ///
catholic = "Catholic" mormon = "Mormon" jewish = "Jewish" other_rel= "Other Religious Identification" no_relig ="No Religion / No Answer" ///
attend01= "Religiosity") 


****************FIGURE D2. Sentiments Toward Party Coalitions & Party ID (Controlling for Personal Belonging to Party-Aligned Groups)***********	
**N=495, due to data drop -- need to be in one of the "closeness" rated groups to be included in measure
reg partyid DemGroups_pfscore GOPgroups_pfscore ///
	dem_perceptual01 rep_perceptual01 ///
	close_dem_groups close_rep_groups /// 
	polint age01 educ01 income01 attend01, robust
	
coefplot, drop(_cons) ci(95) xline(0) scheme(plottig) xlabel(-2(.5)2)  ///
coeflabels (DemGroups_pfscore = "{bf: Democratic Coalition Score}" GOPgroups_pfscore = "{bf: Republican Coalition Score}" ///
dem_perceptual01 = "Perceptual Accuracy (Dem Groups)" rep_perceptual01 = "Perceptual Accuracy (Rep Groups)" ///
close_dem_groups = "Closeness to Democratic Groups" close_rep_groups = "Closeness to Republican Groups" ///
polint= "Political Interest" age01 = "Age" educ01 = "Education" income01 = "Income" attend01= "Religiosity") 

***************TABLE D2.  Group Sentiments and Partisanship Strength (by Party)***********	
**democrats only
ologit pid_strength_new DemGroups_pfscore GOPgroups_pfscore ///
	dem_perceptual01 rep_perceptual01 ///
	polint age01 educ01 income01 gender ///
	black hisp other_race ///
	catholic mormon jewish other_rel no_relig attend01 if party01==0, robust
**For -1 to +1 SD change in Dem group sentiments	
**Dem change in pr(leaner) .155 - .313 = -0.158
**Dem change in pr(strong partisan) .617 - .397 = 0.22
margins, at(DemGroups_pfscore=(-1 1))
**For -1 to +1 SD change in Rep group sentiments
**Dem change in pr(leaner) .228 - .194 = 0.034
**Dem change in pr(strong partisan) .514 - .563 = -0.049
margins, at(GOPgroups_pfscore=(-1 1))


**republicans only
ologit pid_strength_new DemGroups_pfscore GOPgroups_pfscore ///
	dem_perceptual01 rep_perceptual01 ///
	polint age01 educ01 income01 gender ///
	black hisp other_race ///
	catholic mormon jewish other_rel no_relig attend01 if party01==1, robust	
**For -1 to +1 SD change in Dem group sentiments	
**Rep change in pr(leaner) .375 - .26 = 0.115
**Rep change in pr(strong partisan) .352 - .481 = -0.129
margins, at(DemGroups_pfscore=(-1 1))
**For -1 to +1 SD change in Rep group sentiments
**Rep change in pr(leaner) .223 - .438 = -0.215
**Rep change in pr(strong partisan) .524 - .287 = 0.237
margins, at(GOPgroups_pfscore=(-1 1))


***************FIGURE D3:  Sentiments Toward Party Coalitions & Party Identification (w/ Ideology)***********
reg partyid DemGroups_pfscore GOPgroups_pfscore /// 
	dem_perceptual01 rep_perceptual01 ///
	ideo7 polint age01 educ01 income01 gender ///
	black hisp other_race ///
	catholic mormon jewish other_rel no_relig attend01, robust

coefplot, drop(_cons) ci(95) xline(0) scheme(plottig) xlabel(-2(.5)2)  ///
coeflabels (DemGroups_pfscore = "{bf: Democratic Coalition Score}" GOPgroups_pfscore = "{bf: Republican Coalition Score}" ///
dem_perceptual01 = "Perceptual Accuracy (Dem Groups)" rep_perceptual01 = "Perceptual Accuracy (Rep Groups)" ///
ideo7 = "Ideology" polint= "Political Interest" age01 = "Age" educ01 = "Education" income01 = "Income" gender = "Female" ///
black = "African-American" hisp = "Hispanic" other_race = "Other Racial Identification" ///
catholic = "Catholic" mormon = "Mormon" jewish = "Jewish" other_rel= "Other Religious Identification" no_relig ="No Religion / No Answer" ///
attend01= "Religiosity") 

***************FIGURE D4:  Sentiments Toward Party Coalitions, Perceptual Accuracy, and Party ID (w/ Ideology)***********
	*Effects for Affect toward Dem Groups at different levels of Democratic perceptual accuracy
reg partyid c.DemGroups_pfscore##c.dem_perceptual01 c.GOPgroups_pfscore##c.rep_perceptual01 ///
	ideo7 polint age01 educ01 income01 gender ///
	black hisp other_race ///
	catholic mormon jewish other_rel no_relig attend01, robust
	
margins, dydx(DemGroups_pfscore) at (dem_perceptual01=(0(.2)1))

marginsplot, level(95) recastci(rarea) ciopts(fcolor(gs2%35) fintensity(55) lcolor(gs8%75) lpattern(dash)) ///
plotopts(msymbol(T) mcolor(black)) ///
scheme(plotplain)  yline(0) ///
addplot(hist dem_perceptual01,  title( " ") ylabel(-1(.5)1) ytitle("{bf: Conditional Effect of Democratic-Groups Sentiments on PID}", size(small)) ///
xtitle("{bf: Perceptual Accuracy (Democratic Groups)}", size(medsmall)) ///
yaxis(2) yscale(alt axis(2)) percent ///
ylabel(0 "0%" 5 "5%" 10 "10%" 15 "15%" 20 "20%" 25 "25%" 30 "30%", labcolor(black*.9) axis(2)) ///
ytitle("{it: Percent of Sample}", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black*.5)) ///
legend(off) ///
xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
name(g3,replace)

margins, dydx(GOPgroups_pfscore) at (rep_perceptual01=(0(.2)1))

	*Effects for Affect toward Rep Groups at different levels of Republican perceptual accuracy
marginsplot, level(95) recastci(rarea) ciopts(fcolor(gs2%35) fintensity(55) lcolor(gs8%75) lpattern(dash)) ///
plotopts(msymbol(T) mcolor(black)) ///
scheme(plotplain) yline(0) ///
addplot(hist rep_perceptual01,  title( " ") ylabel(-1(.5)1) ytitle("{bf: Conditional Effect of Republican-Groups Sentiments on PID}", size(small)) ///
xtitle("{bf: Perceptual Accuracy (Republican Groups)}", size(medsmall)) ///
yaxis(2) yscale(alt axis(2)) percent ///
ylabel(0 "0%" 5 "5%" 10 "10%"  15 "15%" 20 "20%" 25 "25%" 30 "30%", labcolor(black*.9) axis(2)) ///
ytitle("{it: Percent of Sample}", axis(2) orientation(rvertical))  fcolor(white%10) lcolor(black*.5)) ///
legend(off) ///
xsize(6.5) ysize(4.5) graphregion(margin(vsmall)) ///
name(g4,replace)	

graph combine g3 g4, ycommon iscale(.6) graphregion(margin(tiny))
